package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper {

    /**
     * 根据分类id查询菜品数量
     * @param categoryId
     * @return
     */
    @Select("select count(id) from dish where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);

    @AutoFill(OperationType.INSERT)
    void insertDish(Dish dish);

//    List<DishVO> pageWithPage(@Param("start") int start, @Param("queryDTO") DishPageQueryDTO queryDTO);
//
//    @Select("select count(1) from dish left join category where dish.category_id = category.id ")
//    int countDish(DishPageQueryDTO queryDTO);

    Page<DishVO> pageQuery(DishPageQueryDTO queryDTO);

    void deleteBatch(List<Long> ids);

    @Select("select * from dish where id =#{id}")
    Dish getById(Long id);

    /**
     * 根据ID修改菜品
     * @param dish
     */
    @AutoFill(OperationType.UPDATE)
    void updateById(Dish dish);

    /**
     *根据套餐ID查询菜品
     * @param dish
     * @return
     */

    List<Dish> getByCategoryId(Dish dish);

}
